package com.example.yeb.yebserver.exception;

import com.example.yeb.yebserver.config.ResultVO;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @description: ExceptionControllerAdvice
 * @author: sww
 * @create: 2020-07-25 13:19:09
 **/
@ControllerAdvice
@ResponseBody
@Order(Ordered.HIGHEST_PRECEDENCE)
public class ExceptionControllerAdvice {
    protected final org.slf4j.Logger log = LoggerFactory.getLogger(ExceptionControllerAdvice.class);

    /**
     * @param ex
     * @return
     */
    @ExceptionHandler(BusinessException.class)
    public ResultVO<Object> baseException(BusinessException ex) {
        return new ResultVO<>(ex.getCode(), ex.getMsg());
    }


}
